package com.yiwenup.exception.basic;

import com.yiwenup.exception.config.I18nConfig;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 异常
 **/
@Getter
@AllArgsConstructor
public class BaseException extends RuntimeException {
    /**
     * 序列化
     */
    private static final long serialVersionUID = -6264322265503508833L;

    /**
     * 错误码
     */
    private final String errorCode;

    /**
     * 错误信息
     */
    private final String errorMsg;

    /**
     * 格式化构造器
     *
     * @param errorCode 错误码
     * @param args      参数信息
     */
    public BaseException(String errorCode, Object... args) {
        String msg = I18nConfig.formatMsg(errorCode, args);
        this.errorCode = errorCode;
        this.errorMsg = msg;
    }
}
